package org.usmile.algorithms.huawei.acm;

import java.util.Scanner;

// https://blog.csdn.net/qq_34465338/article/details/128713067
public class _Linux发行版的数量 {
    private static int[] parent;
    private static int[] size;
    private static int max;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        parent = new int[n];
        size = new int[n];
        for (int i = 0; i < n; i ++) {
            parent[i] = i;
            size[i] = 1;
        }
        int[][] isConnected = new int[n][n];
        for (int i = 0; i < n; i++) {
            String[] currStr = sc.nextLine().split(" ");
            int[] connected = new int[n];
            for (int j = 0; j < n; j ++) {
                connected[j] = Integer.parseInt(currStr[j]);
            }

            isConnected[i] = connected;
        }
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (isConnected[i][j] == 1){
                    union(i, j);
                }
            }
        }

        System.out.println(max);
    }

    private static void union(int i, int j) {
        int iRoot = find(i);
        int jRoot = find(j);
        if (iRoot != jRoot) {
            if (size[iRoot] < size[jRoot]) {
                parent[iRoot] = jRoot;
                size[jRoot] += size[iRoot];
                max = Math.max(max, size[jRoot]);
            } else {
                parent[jRoot] = iRoot;
                size[iRoot] += size[jRoot];
                max = Math.max(max, size[iRoot]);
            }
        }
    }

    private static int find(int i) {
        while (i != parent[i]) {
            parent[i] = parent[parent[i]];
            i = parent[i];
        }

        return i;
    }
}
